package uqbar.comm.netty.arduino.protocol.simple;

import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;

import uqbar.comm.netty.MockOutputHandler;
import uqbar.comm.netty.protocol.Protocol;
import uqbar.comm.netty.protocol.ProtocolEncoder;

public class ArduinoSimpleClient implements ChannelPipelineFactory {

	public ChannelPipeline getPipeline() throws Exception {
		return Channels.pipeline(this.createEncoder(this.createProtocol()), this.createHandler());
	}

	protected Protocol createProtocol() {
		return new SimpleProtocol();
	}

	protected ChannelHandler createHandler() {
		return new MockOutputHandler();
	}

	protected ChannelHandler createEncoder(final Protocol protocol) {
		return new ProtocolEncoder(protocol);
	}
}
